package com.spring.api.fallbackFactory;

import com.spring.api.entities.Dept;
import com.spring.api.service.ConsumerClientService;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author hezx
 */
@Component
public class ConsumerClientFallBackFactory implements FallbackFactory<ConsumerClientService> {

    @Override
    public ConsumerClientService create(Throwable throwable) {
        return new ConsumerClientService() {

            @Override
            public Dept get(Long id) {
                return new Dept("0", "服务出现异常，暂停服务", "服务出现异常，暂停服务");
            }

            @Override
            public List<Dept> findAll() {
                return null;
            }
        };
    }
}
